var OrderApi = {
  getOutOrderMachiningList(orderId) {
    var self = this;
    return ajaxRequest('putOutNew/getOrderInWarehouseType', {
      orderId: orderId
    }).then(function (data) {
      data.unshift({
        type: -1,
        materialType: '整架'
      });
      var machiningList = self.formatOutOrderMachiningList(data);
      return machiningList;
    });
  },

  formatOutOrderMachiningList(machiningList) {
    machiningList = _.map(machiningList, function (machining) {
      var type = machining.type;
      var value;
      if (type === -1) {
        value = 'all'
      } else if (type === 0) {
        value = machining.materialType;
      } else {
        value = `machineMap-${type}`;
      }

      var materialType = machining.materialType;
      if (materialType === '') {
        materialType = ' ';
      }
      return {
        value: value,
        label: materialType
      };
    });
    return machiningList;
  }
};
